#include "ParticleSystem.h"

namespace lib3dw
{
	ParticleSystem::ParticleSystem()
	{
		enabled = true;
		translationVector = Vector3();
		for(int i = 0; i < 256; i++)
		{
			particles.push_back(new Particle());
		}
	}
	
	ParticleSystem::~ParticleSystem()
	{
		delete translationVector;
	}

	void ParticleSystem::Translate(float newX, float newY, float newZ)
	{
		translationVector.x = newX;
		translationVector.y = newY;
		translationVector.z = newZ;
		for(particleIterator = particles.begin(); particleIterator != particles.end(); ++particleIterator)
		{
			(*particleIterator)->x = newX;
			(*particleIterator)->y = newY;
			(*particleIterator)->z = newZ;
		}
	}
	
	void ParticleSystem::Update()
	{
		for(particleIterator = particles.begin(); particleIterator != particles.end(); ++particleIterator)
		{
			(*particleIterator)->Update(20.0f);
		}
	}
	
	void ParticleSystem::Draw()
	{
		glPushMatrix();
		glTranslated(translationVector.x, translationVector.y, translationVector.z);
		for(particleIterator = particles.begin(); particleIterator != particles.end(); ++particleIterator)
		{
			(*particleIterator)->Draw();
		}
		glPopMatrix();
	}
	
	void ParticleSystem::SetEnabled(bool newEnabled)
	{
		enabled = newEnabled;
	}

	bool ParticleSystem::IsEnabled()
	{
		return enabled;
	}
}
